package com.ruoyi.fun.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.fun.mapper.EcCategoryMapper;
import com.ruoyi.fun.domain.EcCategory;
import com.ruoyi.fun.service.IEcCategoryService;

/**
 * 商品分类Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-08-06
 */
@Service
public class EcCategoryServiceImpl implements IEcCategoryService 
{
    @Autowired
    private EcCategoryMapper ecCategoryMapper;

    /**
     * 查询商品分类
     * 
     * @param categoryId 商品分类主键
     * @return 商品分类
     */
    @Override
    public EcCategory selectEcCategoryByCategoryId(Long categoryId)
    {
        return ecCategoryMapper.selectEcCategoryByCategoryId(categoryId);
    }

    /**
     * 查询商品分类列表
     * 
     * @param ecCategory 商品分类
     * @return 商品分类
     */
    @Override
    public List<EcCategory> selectEcCategoryList(EcCategory ecCategory)
    {
        // 移除调试日志，优化性能
        return ecCategoryMapper.selectEcCategoryList(ecCategory);
    }

    /**
     * 新增商品分类
     * 
     * @param ecCategory 商品分类
     * @return 结果
     */
    @Override
    public int insertEcCategory(EcCategory ecCategory)
    {
        ecCategory.setCreateTime(DateUtils.getNowDate());
        ecCategory.setOrgId(SecurityUtils.getDeptId());
        return ecCategoryMapper.insertEcCategory(ecCategory);
    }

    /**
     * 修改商品分类
     * 
     * @param ecCategory 商品分类
     * @return 结果
     */
    @Override
    public int updateEcCategory(EcCategory ecCategory)
    {
        ecCategory.setUpdateTime(DateUtils.getNowDate());
        return ecCategoryMapper.updateEcCategory(ecCategory);
    }

    /**
     * 批量删除商品分类
     * 
     * @param categoryIds 需要删除的商品分类主键
     * @return 结果
     */
    @Override
    public int deleteEcCategoryByCategoryIds(Long[] categoryIds)
    {
        Long orgId = SecurityUtils.getDeptId();
        return ecCategoryMapper.deleteEcCategoryByCategoryIds(categoryIds, orgId);
    }

    /**
     * 删除商品分类信息
     * 
     * @param categoryId 商品分类主键
     * @return 结果
     */
    @Override
    public int deleteEcCategoryByCategoryId(Long categoryId)
    {
        Long orgId = SecurityUtils.getDeptId();
        return ecCategoryMapper.deleteEcCategoryByCategoryId(categoryId, orgId);
    }

    /**
     * 根据categoryId和组织ID查询Category
     * 
     * @param categoryId Category主键
     * @param orgId 组织ID
     * @return Category
     */
    @Override
    public EcCategory selectEcCategoryByCategoryIdAndOrgId(Long categoryId, Long orgId)
    {
        return ecCategoryMapper.selectEcCategoryByCategoryIdAndOrgId(categoryId, orgId);
    }

    /**
     * 根据组织ID查询Category列表
     * 
     * @param eccategory Category
     * @param orgId 组织ID
     * @return Category集合
     */
    @Override
    public List<EcCategory> selectEcCategoryListByOrgId(EcCategory eccategory, Long orgId)
    {
        return ecCategoryMapper.selectEcCategoryListByOrgId(eccategory, orgId);
    }
}